﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter03
{
    public class MainWindowViewModel
    {
        private List<Unit> catalogues;

        public MainWindowViewModel()
        {
            catalogues = new List<Unit>();
            catalogues.Add(new Unit { Num = 1, Title = "创建及使用类" });
            catalogues.Add(new Unit { Num = 2, Title = "类和结构" });
            catalogues.Add(new Unit
            {
                Num = 3,
                Title = "类",
                ChildCatalogues = new List<Unit>
                {
                    new Unit { Num = 3.1, Title = "数据成员" }, 
                    new Unit { Num = 3.2, Title = "函数成员" },
                    new Unit { Num = 3.3, Title = "只读字段" },
                }
            });
            catalogues.Add(new Unit { Num = 4, Title = "匿名类型" });
            catalogues.Add(new Unit
            {
                Num = 5,
                Title = "结构",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 5.1, Title = "结构是值类型" }, 
                    new Unit { Num = 5.2, Title = "结构和继承" },
                    new Unit { Num = 5.3, Title = "结构的构造函数" }, 
                }
            });
            catalogues.Add(new Unit { Num = 6, Title = "弱引用" });
            catalogues.Add(new Unit { Num = 7, Title = "部分类" });
            catalogues.Add(new Unit { Num = 8, Title = "静态类" });
            catalogues.Add(new Unit
            {
                Num = 9,
                Title = "Object 类",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 9.1, Title = "System.Object() 方法" }, 
                    new Unit { Num = 9.2, Title = "ToString() 方法" },
                }
            });
            catalogues.Add(new Unit { Num = 10, Title = "扩展方法" });
            catalogues.Add(new Unit { Num = 11, Title = "小结" });
        }

        public List<Unit> Catalogues
        {
            get { return catalogues; }
        }

        public class Unit
        {
            public double Num { get; set; }
            public string Title { get; set; }
            public string Sample { get; set; }
            public List<Unit> ChildCatalogues { get; set; }
        }

        public override string ToString()
        {
            return "第03章 对象和类型";
        }
    }
}
